package org.c41.net;

import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class UDPPacket {

	DatagramPacket packet;
	
	public UDPPacket(byte[] buff){
		this(new DatagramPacket(buff, buff.length));
	}
	
	public UDPPacket(byte[] buff, String address, int port) throws UnknownHostException{
		this(new DatagramPacket(buff, buff.length, InetAddress.getByName(address), port));
	}
	
	UDPPacket(DatagramPacket packet) {
		this.packet=packet;
	}
	
	public void setPort(int port){
		packet.setPort(port);
	}
	
	public int getPort(){
		return packet.getPort();
	}
	
	public String getAddress(){
		return packet.getAddress().getHostAddress();
	}
	
	public void setAddress(String address) throws UnknownHostException{
		packet.setAddress(InetAddress.getByName(address));
	}
	
	public int getLength(){
		return packet.getLength();
	}
	
	public byte[] getData(){
		return packet.getData();
	}
	
}
